package com.sms.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
	public static String getCode(String str) {
		if (str != null) {
			try {
				MessageDigest md5 = null;
				md5 = MessageDigest.getInstance("MD5");
				sun.misc.BASE64Encoder baseEncoder = new sun.misc.BASE64Encoder();
				return baseEncoder.encode(md5.digest(str.getBytes("utf-8")));
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return "";
	}
	public static void main(String [] agrs){
		System.out.println(getCode("hzx2123"));
	}
}